/*
 * @Author: shiguo
 * @Date: 2022-04-15 14:15:07
 * @LastEditors: shiguo
 * @LastEditTime: 2022-06-02 11:03:59
 * @FilePath: /@aks-dev/easyui/screen/text-fit.tsx
 */
/**
 * 全局配置Text
 */

import React from 'react';
import { Platform, Text as Text_spaceName, TextInput as TextInput_spaceName } from 'react-native';
const Text: any = Text_spaceName
const TextInput: any = TextInput_spaceName
const textDefaultStyle = {
    ...Platform.select({
        android: { fontFamily: 'DroidSansFallback' }
    }),
    allowFontScaling: false,
    paddingVertical: 0,
    paddingHorizontal: 0,
};



const textRender = Text.render;
Text.render = function (...args: any[]) {
    const origin = textRender.call(this, ...args);
    return React.cloneElement(origin, {
        style: [textDefaultStyle, origin.props.style]
    });
};


const textInputDefaultStyle = {
    defaultProps: false,
    paddingVertical: 0,
    paddingHorizontal: 0,
    autoCapitalize: "none", //不自动大写
    autoCorrect: false, //不自动纠正拼写
};

const textInputRender = TextInput.render;
TextInput.render = function (...args: any[]) {
    const origin = textInputRender.call(this, ...args);
    return React.cloneElement(origin, {
        style: [textInputDefaultStyle, origin.props.style]
    });
};



/**关闭字体缩放 */
if (!Text.defaultProps) Text.defaultProps = {};
if (!TextInput.defaultProps) TextInput.defaultProps = {};
Text.defaultProps.allowFontScaling = false
TextInput.defaultProps.allowFontScaling = false


